{extend name="public/base" /}
{block name='content'}
{include file='public/content_header' /}
<!--数据列表页面-->
<section class="content">

    <!--顶部搜索筛选-->
<div class="row">
    <div class="col-md-12">
        <div class="box">
            <div class="box-body">
                <form class="form-inline searchForm" id="searchForm" action="{:url('index')}" method="GET">

                    <div class="form-group">
                        <input value="{$_keywords ? $_keywords : '' ;}"
                               name="_keywords" id="_keywords" class="form-control input-sm" placeholder="">
                    </div>
                    
                    
                    <div class="form-group">
                        <button class="btn btn-sm btn-primary" type="submit"><i class="fa fa-search"></i> 查询
                        </button>
                    </div>
                    
                    <div class="form-group">
                        <button onclick="clearSearchForm()" class="btn btn-sm btn-default" type="button"><i
                                class="fa  fa-eraser"></i> 清空查询
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

    <div class="row">
        <div class="col-md-12">
            <div class="box">

                <!--数据列表顶部-->
                <div class="box-header">
                    <div>
                        <a title="添加" data-toggle="tooltip" class="btn btn-primary btn-sm "  href="{:url('add')}">
    <i class="fa fa-plus"></i> 添加
</a>
                        <a class="btn btn-danger btn-sm AjaxButton" data-toggle="tooltip" title="删除选中数据" data-confirm-title="删除确认" data-confirm-content="您确定要删除选中的数据吗？" data-id="checked" data-url="{:url('del')}">
    <i class="fa fa-trash"></i> 删除
</a>
                        
                        <a class="btn btn-success btn-sm ReloadButton" data-toggle="tooltip" title="刷新">
    <i class="fa fa-refresh"></i> 刷新
</a>
                    </div>
                </div>

                <div class="box-body table-responsive">
                    <table class="table table-hover table-bordered datatable" width="100%">
                        <thead>
                        <tr>
                            <th>
    <input id="dataCheckAll" type="checkbox" onclick="checkAll(this)" class="checkbox" placeholder="全选/取消">
</th>
                                        <th>ID</th>
            <th>交易所</th>
            <th>交易对</th>
            <th>别名</th>
<th>当前价格</th>
<th>指数</th>
<th>资金费率</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {foreach name='data' id='item' key='data_key'}
                        <tr>
                            <td>
    <input type="checkbox" onclick="checkThis(this)" name="data-checkbox" data-id="{$item.id}" class="checkbox data-list-check" value="{$item.id}" placeholder="选择/取消">
</td>
                                        <td>{$item.id}</td>
            <td>{$item.exchange}</td>
            <td>{$item.rightname}</td>
            <td>{$item.aliasname}</td>
<td class="mart-{$item.id}">
</td>
<td class="zhishu-{$item.id}">

</td>
<td class="feilv-{$item.id}">

</td>
                            <td class="td-do">
                                <a href="{:url('edit',['id'=>$item.id])}"
                                   class="btn btn-primary btn-xs" title="修改" data-toggle="tooltip">
                                    <i class="fa fa-pencil"></i>
                                    
                                </a>
                                <a class="btn btn-danger btn-xs AjaxButton" data-toggle="tooltip" title="删除"  data-id="{$item.id}" data-confirm-title="删除确认" data-confirm-content='您确定要删除ID为 <span class="text-red">{$item.id}</span> 的数据吗' data-url="{:url('del')}">
    <i class="fa fa-trash"></i>
    
</a>
                                <a class="btn btn-warning  btn-xs yulan"  data-toggle="tooltip" title="预览价格"  data-exchange="{$item.exchange}" data-rightname="{$item.rightname}">
    <i class="fa fa-circle"></i>
    
</a>
                            </td>
							
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                </div>

                <!-- 数据列表底部 -->
                <div class="box-footer">
                    {$page|raw}
                    <label class="control-label pull-right" style="margin-right: 10px; font-weight: 100;">
                        <small>共{$total}条记录</small>&nbsp;
                        <small>每页显示</small>
                        &nbsp;
                        <select class="input-sm" onchange="changePerPage(this)">
                            <option value="10" {if $admin.per_page==10}selected{/if}>10</option>
                            <option value="20" {if $admin.per_page==20}selected{/if}>20</option>
                            <option value="30" {if $admin.per_page==30}selected{/if}>30</option>
                            <option value="50" {if $admin.per_page==50}selected{/if}>50</option>
                            <option value="100" {if $admin.per_page==100}selected{/if}>100</option>
                        </select>
                        &nbsp;
                        <small>条记录</small>
                    </label>
                </div>

            </div>
        </div>
    </div>
</section>
<script>
$('.yulan').click(function(){

var rightname = $(this).attr('data-rightname');

var exchange = $(this).attr('data-exchange');

var url='';

if(exchange=='okex'){
	 url='http://1.coinbmw.com/okex/okex_demo.php';
}

$.ajax({
    url:url,
    type:'get',
    data:{rightname:rightname},
    beforeSend:function () {
        this.layerIndex = layer.load(0, { shade: [0.5, '#393D49'] });
    },
    success:function(data){
        if(data.status == '0'){
			layer.msg(data.msg,{icon: 5});//失败的表情
                      o.removeClass('layui-btn-disabled');
                      return;
                  }else{
                      layer.msg(data.msg, {
                          icon: 6,//成功的表情
                          time: 3000 //1秒关闭（如果不配置，默认是3秒）
                      });
                  }
              },
              complete: function () {
                  layer.close(this.layerIndex);
              },
          });
     

})



var getting = {
        url:'getmarket',
        dataType:'json',
        success:function(res) {
            $.each(res, function (index, val) {
				if(val.market=='还未初始化'){
					$(".mart-"+index).css({"color":"rgb(197 193 216)"});					
				}else{
					var min = 1;
					var max = 2;
					var rand = Math.floor(Math.random()*(max-min+1))+min;
					if(rand==1){
						$(".mart-"+index).css({"color":"red"});
					}else{
						$(".mart-"+index).css({"color":"rgb(150, 193, 157)"});
					}
				}
				$(".mart-"+index).html(val.market);
				$(".zhishu-"+index).html(val.zhishu);
				$(".feilv-"+index).html(val.feilv);
			})
          setTimeout(function(){$.ajax(getting);},2000);//1秒后定时发送请求
        }
};
$.ajax(getting)



</script>
{/block}


